<?
session_start();
class QDSvc{
  protected static $object = array();
	function addClass($id,&$obj){
		$_SESSION[$id] = $obj;
	}	
	function getObj($id){
		return $_SESSION[$id];
	}
	static function run(){
		if ($_REQUEST['exw_action']){
			$arrArg = split('\.',$_REQUEST['exw_action']);
			$objId = $arrArg[0];
			$methodName = $arrArg[1];
	        if (!array_key_exists($objId,$_SESSION)){
	            print 'object '.$objId.' not in session';
	            return;
	        }
			if (!in_array('svc_'.$methodName,get_class_methods (get_class  ($_SESSION[$objId])))){
	            print 'method svc_'.$methodName.' not in session object '.$objId.' of class '.get_class  ($objId);
				return;
	        }
	        $outputMethod = array_key_exists_assign_default('fmt_output',$_REQUEST,'json');
	        switch ($outputMethod){
	        	case 'json' :
	        		die(myjson(call_user_func(array($_SESSION[$objId],'svc_'.$methodName))));
	        	break;
	        	case 'text' :
	        		die (call_user_func(array($_SESSION[$objId],'svc_'.$methodName)));
	        	break;
	        }
			            		
		}
	}
}
?>